package com.mc.servlet;

import com.mc.VO.STVO;
import com.mc.VO.TTVO;
import com.mc.service.STService;
import com.mc.service.TTService;
import com.mc.service.impl.STServiceImpl;
import com.mc.service.impl.TTServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description 团队人员控制器
 * @author wangcf
 * @date 2023/2/16 11:11
 * @version 1.0
 */
@WebServlet("/teampeople.action")
public class TeamPeopleServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String mess=req.getParameter("mess");
        System.out.println("mess"+mess);
        if(mess!=null){
            req.setAttribute("mess",mess);
        }
        String midStr=req.getParameter("mid");
        System.out.println("midStr"+midStr);
        int mid=Integer.parseInt(midStr);
        System.out.println("mid"+mid);
        STService stService=new STServiceImpl();
        TTService ttService=new TTServiceImpl();
        String teamidStr=req.getParameter("teamid");
        int teamid=Integer.parseInt(teamidStr);
        List<STVO> stvoList= stService.findByTeamId(teamid);
        List<TTVO> ttvoList=ttService.findByTeamIdView(teamid);
        req.setAttribute("teamid",teamid);
        req.setAttribute("teamstudent",stvoList);
        req.setAttribute("teamteacher",ttvoList);
        req.setAttribute("mid",mid);
        System.out.println(mid);
        req.getRequestDispatcher("teampeople.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
